//
//  STEUserDataManager.m
//  ste
//
//  Created by iRDC on 7/4/13.
//  Copyright (c) 2013 Lekima. All rights reserved.
//

#import "STEUserDataManager.h"

@implementation STEUserDataManager
static  STEUserDataManager* sharedSTEUserDataManagerInstance = nil;
+(STEUserDataManager*) sharedSTESocialNetworkManager
{
	@synchronized(self)
	{
		if (sharedSTEUserDataManagerInstance == nil) {
			sharedSTEUserDataManagerInstance = [[STEUserDataManager alloc] init];
           
		}
	}
    return sharedSTEUserDataManagerInstance;
}
- (void) TestDb
{
    @autoreleasepool
    {
        NSError *theError = NULL;
        CSqliteDatabase *theDatabase = [[CSqliteDatabase alloc] initTemporary:&theError];
        if (theError)
        {
            NSLog(@"%@", theDatabase);
            NSLog(@"Error: %@", theError);
        }
        
        BOOL theResult;
        theResult = [theDatabase executeExpression:@"CREATE TABLE foo (name VARCHAR(100))" error:&theError];
        if (theError)
        {
            NSLog(@"%d", theResult);
            NSLog(@"Error: %@", theError);
        }
        
        theResult = [theDatabase executeExpression:@"INSERT INTO foo VALUES ('testname') " error:&theError];
        if (theError)
        {
            NSLog(@"%d", theResult);
            NSLog(@"Error: %@", theError);
        }
        
        theResult = [theDatabase executeExpression:@"INSERT INTO foo VALUES ('testname2') " error:&theError];
        if (theError)
        {
            NSLog(@"%d", theResult);
            NSLog(@"Error: %@", theError);
        }
        
        CSqliteStatement *theStatement = [theDatabase statementWithString:@"SELECT * FROM foo"];
        [theStatement enumerateObjectsUsingBlock:^(CSqliteRow *row, NSUInteger idx, BOOL *stop) {
            NSLog(@"%@", row);
        }];
        
        NSLog(@"Fast enum");
        [theStatement reset:NULL];
        
        if (theError)
        {
            NSLog(@"Error: %@", theError);
        }
        for (CSqliteRow *theRow in theStatement)
        {
            NSLog(@"%@", theRow);
        }
        
        theStatement = NULL;
    }
    
    
}
@end
